<template>
    <a-drawer :title="`事件`" v-model:visible="visible" width="80%" v-if="visible" unmount-on-close :footer="false">
        <ma-crud ref="crudRef" :columns="columns" :options="options" :scrollbar="true">

        </ma-crud>
    </a-drawer>
</template>

<script setup>
import {computed, inject, ref,reactive} from "vue";
import feeTypeEvent from "@/api/finance/feeTypeEvent.js";
const crudRef = ref()
const parentCrudRef = inject('crudRef')
const record = inject('record')
const visible = defineModel()
const options = ref({
  rowSelection: {showCheckedAll: true},
  showTools: true,
  pageLayout: 'normal',
  // 默认统一设置列宽度
  columnWidth: 0,
  operationColumn: true,
  operationColumnWidth: 160,
  pk: 'id',
  api: feeTypeEvent.getList,
  beforeRequest:(requestParams)=>{
    requestParams.fee_type_id = record.value.id
    return requestParams
  },
  beforeAdd:(params)=>{
    params.fee_type_id = record.value.id
    return params
  },
  add: {
    show: true,
    api: feeTypeEvent.save,
    auth: ['finance:feeTypeEvent:save']
  },
  edit: {
    show: true,
    api: feeTypeEvent.update,
    auth: ['finance:feeTypeEvent:update']
  },
  delete: {
    show: true,
    api: feeTypeEvent.deletes,
    auth: ['finance:feeTypeEvent:delete']
  }
})

const columns = reactive([
  {
      title: "id",
      dataIndex: "id",
      formType: "input",
      addDisplay:false,
      editDisplay:false,
      hide:true,
  },
  {
      title: "添加模型",
      dataIndex: "add_model",
      formType: "select",
      dict:{
        data:[
            {'label':'应收','value':'CustomerFee'},
            {'label':'应付','value':'SupplierFee'},
            {'label':'销售成本','value':'Cost'},
            {'label':'销售提成','value':'Bonus'},
        ],
        translation:true
      }
  },
  {
      title: "复制模型",
      dataIndex: "copy_model",
      formType: "select",
      dict:{
        data:[
            {'label':'应收','value':'CustomerFee'},
            {'label':'应付','value':'SupplierFee'},
            {'label':'销售成本','value':'Cost'},
            {'label':'销售提成','value':'Bonus'},
        ],
        translation:true
      }
  },
  {
      title: "备注",
      dataIndex: "remark",
      formType: "textarea",
  },
])
</script>